package mspbots.next.ticket.core.data.rules;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import javax.validation.Valid;
import java.util.List;

/**
 * mspbots.next.ticket.core.data.rules.RuleTemplateController
 *
 * @author <a href="https://github.com/vnobo">Alex bob</a>
 * @date Created by 2020/12/15
 */
@RestController
@RequestMapping("rules/template")
@RequiredArgsConstructor
public class RulesTemplatesController {

    private final RulesTemplatesServiceImpl ruleTemplateService;

    @GetMapping
    public Flux<RulesTemplate> findByAll() {
        return this.ruleTemplateService.findByAll();
    }

    @PostMapping
    public Mono<RulesTemplate> saveOne(@Valid @RequestBody RulesTemplateRequest request) {
        return this.ruleTemplateService.saveOne(request);
    }

    @PostMapping("batch")
    public Flux<RulesTemplate> batchSave(@Valid @RequestBody List<RulesTemplateRequest> requests) {
        return this.ruleTemplateService.batchSave(requests);
    }
}
